<?php
/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

require_once 'configuration.php';

$conf = new JConfig();

//printu($_SERVER);

$db_conf = $conf->db['2.mpakfm.cz8.ru'];

$cn = mysql_connect($db_conf['host'], $db_conf['user'], $db_conf['password']);
mysql_select_db($db_conf['database'], $cn);
mysql_query('SET NAMES UTF8');

$sql = "INSERT INTO jos_cron_task (`task`) VALUES ('test')";
mysql_query($sql);
$task_id = mysql_insert_id();

printu($task_id,'task_id');
$file_path = 'http://2.mpakfm.cz8.ru/administrator/index.php?option=com_shop&view=price&stage=price_ok';
$curl = curl_init($file_path);
curl_setopt($curl, CURLOPT_HEADER ,1);
//curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
//curl_setopt($curl, CURLOPT_USERAGENT,'Googlebot/2.1 (+http://www.google.com/bot.html)');
//curl_setopt($curl, CURLOPT_NOBODY ,1);
curl_setopt($curl, CURLOPT_RETURNTRANSFER ,1);
$res = curl_exec($curl);
//$image_size = curl_getinfo($curl,CURLINFO_CONTENT_LENGTH_DOWNLOAD);
$http_code = curl_getinfo($curl,CURLINFO_HTTP_CODE);
curl_close($curl);

printu($file_path,'$file_path');
printu($http_code,'http_code');
printu($res,'res');

function printu ($obj,$title='',$out='ajax') {
        if ($obj===true) $obj = 'TRUE (bool)';
        if ($obj===false) $obj = 'FALSE (bool)';
        if ($obj===NULL) $obj = 'NULL';
        //if ($out==='log' || ($out==='ajax' && !Config::$debug)) {
        if ($out==='log') {
            self::log( ($title == '' ? '': "$title: ") . print_r($obj,true)."\n",'info');
        }
        if ($out===true) return ($title == '' ? '': "$title: ") .print_r($obj,true)."\n";

        elseif ($out=='ajax') echo ($title == '' ? '': "$title: ") .print_r($obj,true)."\n";
        else echo '<div align="left" style="text-align:left; background-color:#FFFAFA; border: 1px solid silver; margin: 10px 10px 10px 10px; padding: 10px 10px 10px 10px;">',$title == '' ? '': "<b>$title:&nbsp;</b>", nl2br(str_replace(array(' ','<','>'),array('&nbsp;','&lt;','&gt;'),print_r($obj,true))),'</div>';
}

?>
